import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'

import postRoleService from '/@/api/cn/core/sign/postRoleService'

import type { PostRole } from '/@/model/cn/core/sign/eo/PostRole'
import type { PostRoleQO } from '/@/model/cn/core/sign/qo/PostRoleQO'
import type { PostRoleVO } from '/@/model/cn/core/sign/vo/PostRoleVO'

interface PostRoleState {
}

export const usePostRoleStore = defineStore({
  id: 'postRole',
  state: (): PostRoleState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<PostRole>): Promise<Res<PostRole>> {
      return new Promise<Res<PostRole>>((resolve, reject) => {
        postRoleService.save(param).then((res: AxiosResponse<Res<PostRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<PostRole>): Promise<Res<PostRole>> {
      return new Promise<Res<PostRole>>((resolve, reject) => {
        postRoleService.saveBatch(param).then((res: AxiosResponse<Res<PostRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<PostRole>): Promise<Res<PostRole>> {
      return new Promise<Res<PostRole>>((resolve, reject) => {
        postRoleService.update(param).then((res: AxiosResponse<Res<PostRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<PostRole>): Promise<Res<PostRole>> {
      return new Promise<Res<PostRole>>((resolve, reject) => {
        postRoleService.updateBatch(param).then((res: AxiosResponse<Res<PostRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<PostRole>): Promise<Res<PostRole>> {
      return new Promise<Res<PostRole>>((resolve, reject) => {
        postRoleService.remove(param).then((res: AxiosResponse<Res<PostRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<PostRole>): Promise<Res<PostRole>> {
      return new Promise<Res<PostRole>>((resolve, reject) => {
        postRoleService.removeBatch(param).then((res: AxiosResponse<Res<PostRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<PostRoleQO>): Promise<Res<PostRole>> {
      return new Promise<Res<PostRole>>((resolve, reject) => {
        postRoleService.count(param).then((res: AxiosResponse<Res<PostRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<PostRoleQO>): Promise<Res<PostRole>> {
      return new Promise<Res<PostRole>>((resolve, reject) => {
        postRoleService.pk(param).then((res: AxiosResponse<Res<PostRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<PostRoleQO>): Promise<Res<PostRole>> {
      return new Promise<Res<PostRole>>((resolve, reject) => {
        postRoleService.query(param).then((res: AxiosResponse<Res<PostRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<PostRoleQO>): Promise<Res<PostRole>> {
      return new Promise<Res<PostRole>>((resolve, reject) => {
        postRoleService.paging(param).then((res: AxiosResponse<Res<PostRole>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<PostRoleQO>): Promise<Res<PostRoleVO>> {
      return new Promise<Res<PostRoleVO>>((resolve, reject) => {
        postRoleService.countVo(param).then((res: AxiosResponse<Res<PostRoleVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<PostRoleQO>): Promise<Res<PostRoleVO>> {
      return new Promise<Res<PostRoleVO>>((resolve, reject) => {
        postRoleService.pkVo(param).then((res: AxiosResponse<Res<PostRoleVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<PostRoleQO>): Promise<Res<PostRoleVO>> {
      return new Promise<Res<PostRoleVO>>((resolve, reject) => {
        postRoleService.queryVo(param).then((res: AxiosResponse<Res<PostRoleVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<PostRoleQO>): Promise<Res<PostRoleVO>> {
      return new Promise<Res<PostRoleVO>>((resolve, reject) => {
        postRoleService.pagingVo(param).then((res: AxiosResponse<Res<PostRoleVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function usePostRoleStoreWithout() {
  return usePostRoleStore(store)
}
